<?php

/**
 * This is the model class for table "tbl_inventoryquanity".
 *
 * The followings are the available columns in table 'tbl_inventoryquanity':
 * @property string $partno
 * @property string $warehouse
 * @property string $aisle
 * @property string $bin
 * @property double $minqty
 * @property double $reorder
 */
class Inventoryquanity extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Inventoryquanity the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_inventoryquanity';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('partno, warehouse, aisle, bin, minqty, reorder', 'required'),
			array('minqty, reorder', 'numerical'),
			array('partno', 'length', 'max'=>75),
			array('warehouse', 'length', 'max'=>4),
			array('aisle', 'length', 'max'=>10),
			array('bin', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('partno, warehouse, aisle, bin, minqty, reorder', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
                    'inventory'=>array(self::BELONGS_TO,'Inventory','partno'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'partno' => 'Part No',
			'warehouse' => 'Warehouse',
			'aisle' => 'Aisle',
			'bin' => 'Bin',
			'minqty' => 'Min. QTY ',
			'reorder' => 'Max. QTY',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('partno',$this->partno,true);
		$criteria->compare('warehouse',$this->warehouse,true);
		$criteria->compare('aisle',$this->aisle,true);
		$criteria->compare('bin',$this->bin,true);
		$criteria->compare('minquanity',$this->minquanity);
		$criteria->compare('reorder',$this->reorder);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}
